<table id="activities_data"></table>
<script>
$(function(){
	$('#activities_data').datagrid({   
	    url:'../acitivitiesInfoServlet',
	    queryParams:{op:"getActivitiesInfo"},
	    loadMsg:'数据加载中...',
	    pagination:true,
	    rownumbers:true,
	    fitColumns:true,
	  	sortName:'aiid',
	  	sortOrder:'desc',
	  	remoteSort:false,
	    striped:true,
	    pageNumber:1,
	    pageSize:10, 
		pageList:[10,20,30,40,50],
	    columns:[[   
	    	{field:'text1',title:'',checkbox:true,width:100,align:'center'}, 
	        {field:'aiid',title:'活动编号',width:100,align:'center',sortable:true},
	        {field:'ainame',title:'活动名称',width:100,align:'center'},    
	        {field:'aicontent',title:'活动内容',width:100,align:'center'},   
	        {field:'aisdate',title:'活动开始时间',width:100,align:'center'},    
	        {field:'aiedate',title:'活动结束时间',width:100,align:'center'},
	        
	    ]],   
	    
	    toolbar: [{
	    	text:'添加',
			iconCls: 'icon-add',
			handler: function(){
				$("#activities_data_add").dialog("open");
			}
		},'-',{
			text:'删除',
			iconCls: 'icon-remove',
			handler: function(){
				//获取所有被选中的行
				var rows=$("#activities_data").datagrid("getChecked");
				if(rows.length<=0){  //说明没有选中
					$.messager.show({
						title:'温馨提示',
						msg:'请选择您要删除的数据...',
						timeout:2000,
						showType:'slide'
					});
				}else{
					$.messager.confirm('信息确认', '您确定要删除选中的信息吗？', function(r){
						if (r){
							var aiids="";
							//获取所有选中的数据的id
							for(var i=0;i<rows.length-1;i++){
								aiids+=rows[i].aiid+",";
							}
							aiids+=rows[i].aiid;
							
							//向服务器发送请求
							$.post("../acitivitiesInfoServlet?t="+new Date(),{op:"delActivitiesInfo",aiids:aiids},function(data){
								data=parseInt( $.trim(data) );
								if(data>0){
								$.messager.show({
									title:'成功提示',
									msg:'活动套餐信息删除成功...',
									timeout:3000,
									showType:'slide'
								});
								$("#activities_data").datagrid("reload");
								}else{
									$.messager.alert('失败提示','活动套餐信息删除失败，请稍后再试...','error');
								}
							});
						}
					});
				}
			}
		},'-',{
			text:'修改',
			iconCls: 'icon-edit',
			handler: function(){
				var rows=$("#activities_data").datagrid("getChecked");
				if(rows.length<=0){
					$.messager.show({
						title:'温馨提示',
						msg:'请选择您要修改的数据...',
						timeout:2000,
						showType:'slide'
					});
				}else{
					$("#activities_data_update").dialog("open");
					
					$("#company_newsInfo_nltitle_update").val( rows[0].nltitle );
					$("#company_newsInfo_nlcontents_update").val( rows[0].nlcontents );
					$("#company_newsInfo_nlimg_update").val( rows[0].nlimg );
					$("#company_newsInfo_nlimgName_update").val( rows[0].nlimgName );
					$("#company_newsInfo_nldate_update").val( rows[0].nldate );
				}
			}
		
		}]
	});  
	$("#activities_data").datagrid('getPager').pagination({
		beforePageText:'第',
		afterPageText:'页 共{pages}页',
		displayMsg:'当前显示{from}-{to} 条记录 共{total} 条记录'
	})
})





//修改公司新闻
var ue1= UE.getEditor('editor1');
function updateActivitiesInfo(){
	
		var ainame=$.trim( $("#activities_data_ainame_add").val() );
		var aicontent=ue1.getContent();
		var aisdate=$("#activities_data_aisdate_add").datebox('getValue');
		var aiedate=$("#activities_data_aiedate_add").datebox('getValue');
    	
	
	$.post("../acitivitiesInfoServlet?t="+new Date(),{op:"updateActivitiesInfo",nltype:nltype,nltitle:nltitle,nlimgName:nlimgName,nlcontents:nlcontents,nlimg:nlimg,nldate:nldate},function(data){
		data=parseInt( $.trim(data) );
		console.info(data);
		if(data>0){
			$.messager.show({
					title:'成功提示',
					msg:'活动套餐信息修改成功...',
					timeout:3000,
					showType:'slide'
				});
				$("#activities_data_ainame_update").val("");
				$("#activities_data_aicontent_update").val("");
				$("#editor").val("");
				$("#activities_data_aisdate_add").val("");
				$("#activities_data_aisdate_add").val("");
				$("#activities_data_aiedate_add").val("");
				$("#activities_data_update").dialog("close"); //关闭添加对话框
				$("#activities_data").datagrid("reload");
		}else{
			//$.messager.alert('失败提示',活动套餐修改失败，请稍后再说...','error');
		}
	});
}
</script>

<div id="activities_data_add" class="easyui-dialog" title="添加新闻信息" style="width:700px;height:600px;" data-options="iconCls:'icon-add',resizable:true,modal:true,closed:true">  
    <br/>  <br/> 
    
    	 <form action="" style="padding-left:20px;float:left;">
    			<label for="activities_data_ainame_add">活动名称：</label><input type="label" name="ainame" id="activities_data_ainame_add" required style="width:200px" />  <br/>  <br/> 
   		    	<label for="activities_data_aicontent_add">活动内容：
   		    	<div >
    				<script id="editor" type="text/plain" style="width:600px;height:200px;"></script>
    			</div> <br/> 
   		    	<label for="activities_data_aisdate_add">活动开始时间：</label><input  name="nisdate" id="activities_data_aisdate_add" class="easyui-datebox" required style="width:200px"  />  <br/>  <br/> 
   		    	<label for="activities_data_aiedate_add">活动结束时间：</label><input  name="niesdate" id="activities_data_aiedate_add" class="easyui-datebox" required style="width:200px"  />  <br/>  <br/> 
   				<a href="javascript:addActivitiesInfo()" class="easyui-linkbutton" data-options="iconCls:'icon-add'">添加</a>		
   				
   		</form><br/> 
</div>  


<div id="activities_data_update" class="easyui-dialog" title="修改活动套餐信息" style="width:700px;height:800px;" data-options="iconCls:'icon-add',resizable:true,modal:true,closed:true">  
    <br/>  <br/> 
    	 <form action="" style="padding-left:20px;float:left;">
    			<label for="activities_data_ainame_update">活动名称：</label><input type="label" name="ainame" id="activities_data_ainame_update" required style="width:200px" />  <br/>  <br/> 
   		    	<label for="activities_data_aicontent_update">活动内容：
   		    	<div >
    				<script id="editor1" type="text/plain" style="width:600px;height:200px;"></script>
    			</div> <br/> 
   		    	<label for="activities_data_aisdate_update">活动开始时间：</label><input  name="nisdate" id="activities_data_aisdate_update" class="easyui-datebox" required style="width:200px"  />  <br/>  <br/> 
   		    	<label for="activities_data_aiedate_update">活动结束时间：</label><input  name="niesdate" id="activities_data_aiedate_update" class="easyui-datebox" required style="width:200px"  />  <br/>  <br/> 
   				<a href="javascript:updateActivitiesInfo()" class="easyui-linkbutton" data-options="iconCls:'icon-add'">保存</a>		
   				
   		</form><br/> 
</div>
<script>
//添加活动信息
	var ue = UE.getEditor('editor');
    function addActivitiesInfo(){
   	    
		var ainame=$.trim( $("#activities_data_ainame_add").val() );
		var aicontent=ue.getContent();
		var aisdate=$("#activities_data_aisdate_add").datebox('getValue');
		var aiedate=$("#activities_data_aiedate_add").datebox('getValue');
		
    	
    	if(ainame!="" && aicontent!="" && aisdate!="" && aiedate!=""){
			$.post("../acitivitiesInfoServlet?t="+new Date(),{op:"addActivitiesInfo",ainame:ainame,aicontent:aicontent,aisdate:aisdate,aiedate:aiedate},function(data){
				data=parseInt( $.trim(data) );
				if(data>0){
					$.messager.show({
						title:'成功提示',
						msg:'活动套餐信息添加成功...',
						timeout:3000,
						showType:'slide'
					});
					$("#activities_data_ainame_add").val("");
					$("#editor").val("");
					$("#activities_data_aisdate_add").val("");
					$("#activities_data_aiedate_add").val("");
					
					$("#activities_data_add").dialog("close"); //关闭添加对话框
					$("#activities_data").datagrid("reload");
				}else{
					$.messager.alert('失败提示','活动套餐信息添加失败，请稍后再试...','error');
				}
			});
		}else{
			$.messager.show({
				title:'温馨提示',
				msg:'您输入的信息不完整，请确认后再提交...',
				timeout:3000,
			});
  		}
  }

</script>





 